package com.ruoyi.web.controller.gxs;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gxs.domain.GxsGrade;
import com.ruoyi.gxs.service.IGxsGradeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动等级Controller
 * 
 * @author gxs
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/gxs/grade")
public class GxsGradeController extends BaseController
{
    @Autowired
    private IGxsGradeService gxsGradeService;

    /**
     * 查询活动等级列表
     */
//    @PreAuthorize("@ss.hasPermi('gxs:grade:list')")
    @GetMapping("/list")
    public TableDataInfo list(GxsGrade gxsGrade)
    {
        startPage();
        List<GxsGrade> list = gxsGradeService.selectGxsGradeList(gxsGrade);
        return getDataTable(list);
    }

    /**
     * 导出活动等级列表
     */
//    @PreAuthorize("@ss.hasPermi('gxs:grade:export')")
    @Log(title = "活动等级", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GxsGrade gxsGrade)
    {
        List<GxsGrade> list = gxsGradeService.selectGxsGradeList(gxsGrade);
        ExcelUtil<GxsGrade> util = new ExcelUtil<GxsGrade>(GxsGrade.class);
        util.exportExcel(response, list, "活动等级数据");
    }

    /**
     * 获取活动等级详细信息
     */
//    @PreAuthorize("@ss.hasPermi('gxs:grade:query')")
    @GetMapping(value = "/{gxsGradeId}")
    public AjaxResult getInfo(@PathVariable("gxsGradeId") Long gxsGradeId)
    {
        return success(gxsGradeService.selectGxsGradeByGxsGradeId(gxsGradeId));
    }

    /**
     * 新增活动等级
     */
//    @PreAuthorize("@ss.hasPermi('gxs:grade:add')")
    @Log(title = "活动等级", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GxsGrade gxsGrade)
    {
        return toAjax(gxsGradeService.insertGxsGrade(gxsGrade));
    }

    /**
     * 修改活动等级
     */
//    @PreAuthorize("@ss.hasPermi('gxs:grade:edit')")
    @Log(title = "活动等级", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GxsGrade gxsGrade)
    {
        return toAjax(gxsGradeService.updateGxsGrade(gxsGrade));
    }

    /**
     * 删除活动等级
     */
//    @PreAuthorize("@ss.hasPermi('gxs:grade:remove')")
    @Log(title = "活动等级", businessType = BusinessType.DELETE)
	@DeleteMapping("/{gxsGradeIds}")
    public AjaxResult remove(@PathVariable Long[] gxsGradeIds)
    {
        return toAjax(gxsGradeService.deleteGxsGradeByGxsGradeIds(gxsGradeIds));
    }
}
